package com.jdk8.lambda_01;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class File {

    public static String processFile(BufferedReaderProcessor processor) throws IOException {
        try (BufferedReader br = new BufferedReader(new FileReader("Lambda/src/data.txt"))) {
            return processor.process(br);
        }
    }

    public static void main(String[] args) throws IOException {
        /*new BufferedReaderProcessor() {
            @Override
            public String process(BufferedReader b) throws IOException {
                return null;
            }
        };*/

        String oneLine = processFile((BufferedReader br) -> br.readLine());
        System.out.println(oneLine);

        String twoLines = processFile((BufferedReader br) -> br.readLine());
        System.out.println(twoLines);
    }
}
